package com.test.ribbon.service;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
@Service
public class HelloService {
    @Autowired
    RestTemplate restTemplate;

    //添加断路器配置
    @HystrixCommand(fallbackMethod = "helloErr")
    public String hi(String name){
        return restTemplate.getForObject("http://eureka-client/hi?name="+name,String.class);
    }

    //断路器方法
    public String helloErr(String name){
        return "hi,你好"+name+"，我是ribbon断路器。";
    }
}
